import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';

export default async function a005(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	// 筛选 确定
	const key = args[0].target.dataset.feidaoId;
	const check_input = fd.data.node.querySelector('[data-feidao-id=check_' + key + ']') as HTMLInputElement;
	let value = "";
	let sel_value = null;
	if (!check_input.checked) {
		const input = fd.data.node.querySelector('[data-feidao-id="' + key + '"]') as HTMLInputElement;
		const input_value = input.value;
		if (input_value) {
			value = input_value;
			sel_value = { $regex: '.*' + value + '.*', $options: "i" };
		}
	} else {
		sel_value = "";
	}
	const condition = fd.data.condition;
	//刷新列表
	if (sel_value !== null) {
		const p = condition['param'];
		p[key] = sel_value;
		condition['_param'][key] = value;
		await fd.data.refresh_filter_data(fd);
		await fd.data.refresh_data(fd);
	}
}
